<template>
	<view>
		<view class="cateNav">
			<cate-label :screen="screen" @loadData="getDate"></cate-label>
		</view>
		<scroll-view  scroll-y class="itemList bg-white" style="margin-top:44px ;">
			<view class="p-1">
				<view class="d-flex a-center j-start" style="border-bottom: 1px solid #f5f5f5">
					<view class="p-1" style="width: 20%;">
						<image mode="widthFix" style="width: 150rpx;" src="https://static.wojiufafa.cn/pro/39fd8a1e62e4bd373bc6559bb80c313b.jpg"></image>
					</view>
					<view class="d-flex flex-column j-center a-start" style="width: 80%;">
						<text class="text-black" style="overflow:hidden;text-overflow: ellipsis;">
							万芙乐厨房防油贴纸
						</text>
						<text class="text-light-muted font-sm py-1">
							送<text class="text-warning">4</text>积分
						</text>
						<text class="text-light-muted font-md">
							<text class="text-warning">￥12.9</text>
						</text>
					</view>
				</view>
				<view class="d-flex a-center j-start" style="border-bottom: 1px solid #f5f5f5">
					<view class="p-1" style="width: 20%;">
						<image mode="widthFix" style="width: 150rpx;" src="https://static.wojiufafa.cn/pro/39fd8a1e62e4bd373bc6559bb80c313b.jpg"></image>
					</view>
					<view class="d-flex flex-column j-center a-start" style="width: 80%;">
						<text class="text-black" style="overflow:hidden;text-overflow: ellipsis;">
							万芙乐厨房防油贴纸
						</text>
						<text class="text-light-muted font-sm py-1">
							送<text class="text-warning">4</text>积分
						</text>
						<text class="text-light-muted font-md">
							<text class="text-warning">￥12.9</text>
						</text>
					</view>
				</view>
				
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import cateLabel from "@/components/cateLabel/index.vue";
	export default{
		components:{
			cateLabel
		},
		data(){
		  return{
			where:{},
			screen: {
				currentIndex: 0,
				list: [
					{
						name: "新品",
						status: 0,
						key: "news",
						isSingle: 'y',
						order: 'progress'
					},{
						name: "价格",
						status: 0,
						key: "price",
						isSingle: 'n',
						order: 'now_people'
					}, {
						name: "销量",
						status: 0,
						key: "stock",
						isSingle: 'n',
						order: 'create_time'
					}
				]
			},
		 }
		},
		methods:{
			getDate(index){
				//设置检索条件
				this.setWhere(this.screen.list[index]);
				console.log(JSON.stringify(this.screen.list[index]));
				
			},
			//设置where条件
			setWhere(item) {
				if(item.key=='price'){
					if(item.status==0){
						this.where.priceOrder = '';
					}else if(item.status==1){
						this.where.priceOrder = 'asc';
					}else if(item.status==2){
						this.where.priceOrder = 'desc';
					}
				}else if(item.key=='stock'){
					if(item.status==0){
						this.where.salesOrder = '';
					}else if(item.status==1){
						this.where.salesOrder = 'asc';
					}else if(item.status==2){
						this.where.salesOrder = 'desc';
					}
				}else if(item.key=='news'){
					this.where.news = item.status;
				} 
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cateNav{
	position: fixed;
	top: 0;
	right: 0;
	left: 0;
	z-index: 999;
	}
</style>
